<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input class="myinp">
    <button class="btn">点击查看是否需要带伞</button>



    <script>
 

    var a = document.getElementsByClassName("myinp")[0];
        var btn = document.getElementsByClassName("btn")[0];
        btn.onclick = function(){
            var box = a.value;
            var res = box=="下雨了"?'带伞':'不带伞';

            alert(res);
        }

     

  
       
        
    </script>
</body>
</html>